home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7173 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.7 KB

  1. Path: rcp6.elan.af.mil!rscernix!danpop
  2. From: danpop@mail.cern.ch (Dan Pop)
  3. Newsgroups: comp.os.msdos.programmer,comp.lang.c
  4. Subject: Re: open vs fopen?
  5. Date: 16 Feb 96 00:24:45 GMT
  6. Organization: CERN European Lab for Particle Physics
  7. Message-ID: <danpop.824430285@rscernix>
  8. References: <uEYFxc9nX8WX083yn@mbnet.mb.ca> <4f8bev$6tr@hermes.louisville.edu> <2d3avbl60.alamito@marketgraph.xs4all.nl> <4ftusv$181@newshost.cyberramp.net>
  9. NNTP-Posting-Host: ues5.cern.ch
  10. X-Newsreader: NN version 6.5.0 #7 (NOV)
  11.  
  12. In <4ftusv$181@newshost.cyberramp.net> sinan@cyberramp.net (John Noland) writes:
  13.  
  14. >The open() function and its ilk are normally referred to as the "low-level"
  15. >I/O package. fopen() is the "Buffered" or "Standard" I/O package. The 
  16. >strength of the low-level I/O functions is that they offer excellent control,
  17. >particularly when used with binary files.
  18.  
  19. ???  What can read/write do on a binary file that fread/fwrite cannot do?
  20.  
  21. >If you have a special I/O need, you
  22. >can use the low-level I/O routines to fashion the exact I/O package to fit
  23. >your needs. 
  24.  
  25. Same question as above.
  26.  
  27. >The standard I/O package is one such creation. It is designed to provide fast
  28. >buffered I/O, mostly for text situations.
  29.                ^^^^^^^^^^^^^^^^^^^^^^^^^^
  30. ???
  31.  
  32. >For a lot of applications, using the
  33. >standard I/O package is simpler and more effective than using simple low-level
  34. >output. The essential feature is its use of automatic buffering. Buffered 
  35. >I/O means reading and writing data in large chunks from a file to an array
  36. >and back. Reading and writing data in large chunks greatly speeds up the I/O
  37. >operations, while storing in an array allows access to the individual bytes.
  38. >The advantages of this approach should be apparent.
  39.  
  40. Except that you can read and write data in large chunks using stdio 
  41. routines.  The impact of the extra level of buffering is insignificant.
  42.  
  43. >When fopen() is used, several things happen. The file, of course, is opened.
  44. >Second, an external character array is created to act as a buffer. The 
  45. ><stdio.h> file has this buffer set to a size of 512 bytes.
  46.  
  47. To a default size of _minimum_ 256 bytes.  I'm typing this text on a
  48. system which uses a default buffer size of 8192 bytes.  The size of the
  49. buffer can be controlled by the programmer via the setvbuf function.
  50.  
  51. >Technically, in DOS, all I/O is buffered since DOS itseld uses buffers
  52. >for disk I/O. 
  53.  
  54. The same applies to other operating systems (e.g. Unix) except that they
  55. do a much better job at buffering I/O than MSDOS.
  56.  
  57. >Hope this clarifies things.
  58.  
  59. So many inaccurate statements don't clarify things.  On the contrary.
  60.  
  61. Dan
  62. --
  63. Dan Pop
  64. CERN, CN Division
  65. Email: danpop@mail.cern.ch 
  66. Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
  67.